package com.prjsystem.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.prjsystem.common.constant.CMSConstant;
import com.prjsystem.common.util.CMSUtil;
import com.prjsystem.entity.Daily;
import com.prjsystem.entity.DailyWorkBean;
import com.prjsystem.entity.UserInfo;
import com.prjsystem.entity.WorkRequestViewBean;
import com.prjsystem.service.DailyWorkService;
public class DailyWorkAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3466608591837736953L;
	private DailyWorkService dailyWorkService;
	private DailyWorkBean dailyWorkBean = new DailyWorkBean();
	private Daily daily = new Daily();
	private WorkRequestViewBean workRequestViewBean = new WorkRequestViewBean();
	
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	public String init () {
		return SUCCESS;
	}
	// 页面初期化
	public String searchinfo() {
		// 获取session中userInfo中的数据
		UserInfo userInfor = (UserInfo)ActionContext.getContext().getSession().get(CMSConstant.USERINFO);
		// 获取ID中的数据
		String sessionId = userInfor.getId();
		String teamKey = userInfor.getTeamkey();
		daily.setUserId(sessionId);
		daily.setRepDate(CMSUtil.getCurrentDate());
		daily.setTeamKey(teamKey);
		dailyWorkBean.setDaily(daily);
		dailyWorkService.searchAllInfo(dailyWorkBean);
		return SUCCESS;
	}
	

	public String findDaily(){   
		
		dailyWorkBean=dailyWorkService.getDailyByDate(dailyWorkBean);
		return SUCCESS;
	}
	//复写
	public String rewrite(){
		dailyWorkService.rewrite(dailyWorkBean);
		return SUCCESS;
	}
	
	/**
	 * 检索
	 * @throws Exception
	 */
	public String searchWrinfoOfDailyWork() throws Exception {	
		dailyWorkService.searchAllInfo(dailyWorkBean);
		return SUCCESS;
	}
	/**
	 * click the button of update
	 * @return
	 */
	public String update() {
		dailyWorkService.searchDailyWorkInfoByKey(dailyWorkBean);
		return SUCCESS;
	}
	/**
	 * click the button of update
	 * Delete DailyWork By key
	 */
	public String delateDailyInfo() {
    	dailyWorkService.deleteAllInfo(dailyWorkBean);
		return SUCCESS;
	}
	/**
	 * click the button of add
	 * turn to page of addDaily.jsp
	 */
	public String turnAddDaily() {
		dailyWorkService.searchSelectList(dailyWorkBean);
		return SUCCESS;
	}
	 
	public void setDailyWorkBean(DailyWorkBean dailyWorkBean) {
		this.dailyWorkBean = dailyWorkBean;
	}
	public DailyWorkBean getDailyWorkBean() {
		return dailyWorkBean;
	}

	public void setWorkRequestViewBean(WorkRequestViewBean workRequestViewBean) {
		this.workRequestViewBean = workRequestViewBean;
	}
	public WorkRequestViewBean getWorkRequestViewBean() {
		return workRequestViewBean;
	}
	public Daily getDaily() {
		return daily;
	}
	public void setDaily(Daily daily) {
		this.daily = daily;
	}
	public DailyWorkService getDailyWorkService() {
		return dailyWorkService;
	}
	public void setDailyWorkService(DailyWorkService dailyWorkService) {
		this.dailyWorkService = dailyWorkService;
	}
}